package ie.dkit.java3Demulation.drawer;

import ie.dkit.java3Demulation.objects.Line;
import ie.dkit.java3Demulation.objects3d.Line3D;

import java.awt.Graphics;

public class Line3DDrawer extends LineDrawer {

	private boolean perspective;

	private Line line = new Line();

	public Line3DDrawer(Graphics graphics, int xMiddle, int ymiddle) {
		super(graphics, xMiddle, ymiddle);
	}

	public void draw(Line3D line3D) {
		if (perspective) {
			line.getPointA().setX(
					line3D.getPointA().getX() + line3D.getPointA().getZ() / 2);
			line.getPointA().setY(
					line3D.getPointA().getY() + line3D.getPointA().getZ() / 2);
			line.getPointB().setX(
					line3D.getPointB().getX() + line3D.getPointB().getZ() / 2);
			line.getPointB().setY(
					line3D.getPointB().getY() + line3D.getPointB().getZ() / 2);
		} else {
			line.getPointA().setX(line3D.getPointA().getX());
			line.getPointA().setY(line3D.getPointA().getY());
			line.getPointB().setX(line3D.getPointB().getX());
			line.getPointB().setY(line3D.getPointB().getY());
		}
		draw(line);
	}

	public void setPerpective(boolean enable) {
		perspective = enable;
	}
}
